/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.wii.elpro.web.action;

import com.wii.elpro.dao.QuotationDAOInterface;
import com.wii.elpro.dao.hb.QuotationDAOImpl;
import com.wii.elpro.entity.Quotation;
import com.wii.elpro.entity.User;
import com.wii.elpro.web.form.POInternalForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author User
 */
public class POInternalSaveAction extends org.apache.struts.action.Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
   
    public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
          HttpSession sess = request.getSession(true);
        User user = (User)sess.getAttribute("userSession");       
        if(user==null){
            return mapping.findForward("gagalLogin");            
        }  
        QuotationDAOInterface dao = new QuotationDAOImpl();
        POInternalForm f = (POInternalForm)form;
        try{
            Quotation q = dao.getQuotation(f.getId());
            sess.setAttribute("q", q);
        }catch(Exception e){
            e.printStackTrace();
        }
        return mapping.findForward(SUCCESS);
        
    }
}